package com.ebeitech.auction.bean;

import com.ebeitech.library.util.StringUtil;

import java.io.Serializable;

/**
 * Created by alice on 2017/11/1.
 */
public class AuctionPhase implements Serializable {

	public static final String PHASE_STATE_BEGINNING = "1";//阶段进行中
	public static final String QUOTES_TYPE_ADD = "0";// 递增
	public static final String QUOTES_TYPE_MINUS = "1";// 递减

	/**
	 * 阶段Id
	 */
	private String phaseId;
	/**
	 * 阶段名
	 */
	private String phaseName;
	/**
	 * 阶段顺序
	 */
	private int phaseSort;
	/**
	 * 是否显示比例
	 */
	private boolean isShowRate;
	/**
	 * 单位
	 */
	private String unit;
	/**
	 * 0 递增 1递减
	 */
	private String quotesTypeCode;
	/**
	 * 递增/递减
	 */
	private String quotesTypeText;
	/**
	 * 阶段结果
	 */
	private String phaseResult;
	/**
	 * 阶段结果比例
	 */
	private String phaseResultRate;
	/**
	 * 本方阶段结果
	 */
	private String phaseOurResult;

	/**
	 * 本方阶段结果(比例)
	 */
	private String phaseOurResultRate;

	/**
	 * 当前阶段结果竞价人
	 */
	private AuctionBidder resultBidder;

	/**
	 * 限价
	 */
	private String limitPrice;

	/**
	 * 步长
	 */
	private String stepLength;

	/**
	 * 比例分母
	 */
	private String rateDemo;

	/**
	 * 当前阶段的状态
	 * 0:未开始,1:进行中,2:已结束
	 */
	private String phaseState;

	/**
	 * 起拍价
	 */
	private String startPrice;

	/**
	 * 最终报价
	 */
	private String lastBidPrice;

	/**
	 * 最终报价比例
	 */
	private String lastBidRate;

	public String getPhaseId() {
		return phaseId;
	}

	public void setPhaseId(String phaseId) {
		this.phaseId = phaseId;
	}

	public String getPhaseName() {
		return phaseName;
	}

	public void setPhaseName(String phaseName) {
		this.phaseName = phaseName;
	}

	public int getPhaseSort() {
		return phaseSort;
	}

	public void setPhaseSort(int phaseSort) {
		this.phaseSort = phaseSort;
	}

	public boolean isShowRate() {
		return isShowRate;
	}

	public void setShowRate(boolean showRate) {
		isShowRate = showRate;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public String getQuotesTypeCode() {
		return quotesTypeCode;
	}

	public void setQuotesTypeCode(String quotesTypeCode) {
		this.quotesTypeCode = quotesTypeCode;
	}

	public String getQuotesTypeText() {
		return quotesTypeText;
	}

	public void setQuotesTypeText(String quotesTypeText) {
		this.quotesTypeText = quotesTypeText;
	}

	public String getPhaseResult() {
		return phaseResult;
	}

	public void setPhaseResult(String phaseResult) {
		this.phaseResult = phaseResult;
	}

	public String getPhaseResultRate() {
		return phaseResultRate;
	}

	public void setPhaseResultRate(String phaseResultRate) {
		this.phaseResultRate = phaseResultRate;
	}

	public String getPhaseOurResult() {
		return phaseOurResult;
	}

	public void setPhaseOurResult(String phaseOurResult) {
		this.phaseOurResult = phaseOurResult;
	}

	public String getPhaseOurResultRate() {
		return phaseOurResultRate;
	}

	public void setPhaseOurResultRate(String phaseOurResultRate) {
		this.phaseOurResultRate = phaseOurResultRate;
	}

	public AuctionBidder getResultBidder() {
		return resultBidder;
	}

	public void setResultBidder(AuctionBidder resultBidder) {
		this.resultBidder = resultBidder;
	}

	public String getLimitPrice() {
		return limitPrice;
	}

	public String getStepLength() {
		return stepLength;
	}

	public void setStepLength(String stepLength) {
		this.stepLength = stepLength;
	}

	public String getRateDemo() {
		return rateDemo;
	}

	public void setRateDemo(String rateDemo) {
		this.rateDemo = rateDemo;
	}

	public String getStartPrice() {
		return startPrice;
	}

	public void setStartPrice(String startPrice) {
		this.startPrice = startPrice;
	}

	public void setLimitPrice(String limitPrice) {
		this.limitPrice = limitPrice;
	}

	public String getPhaseState() {
		return phaseState;
	}

	public void setPhaseState(String phaseState) {
		this.phaseState = phaseState;
	}

	public String getLastBidPrice() {
		return lastBidPrice;
	}

	public void setLastBidPrice(String lastBidPrice) {
		this.lastBidPrice = lastBidPrice;
	}

	public String getLastBidRate() {
		return lastBidRate;
	}

	public void setLastBidRate(String lastBidRate) {
		this.lastBidRate = lastBidRate;
	}

	public String getPhaseResultRateString(String rate) {
		String result = "";
		if (isShowRate() && !StringUtil.isEmpty(rate)) {
			result = result + "(" + StringUtil.getDefaultString(rate) + "%)";
		}
		return result;
	}

	@Override
	public boolean equals(Object o) {
		if (o == null || !(o instanceof AuctionPhase)) {
			return false;
		}
		AuctionPhase auctionPhase = (AuctionPhase) o;
		return StringUtil.getDefaultString(phaseId).equals(auctionPhase.getPhaseId());
	}

	public int compare(String money1, String money2) {
		if (StringUtil.isEmpty(money1) || StringUtil.isEmpty(money2)) {
			return 0;
		}
		try {
			double d = Double.valueOf(money1) - Double.valueOf(money2);
			if (d > 0) {
				return 1;
			} else if (d < 0) {
				return -1;
			}
		} catch (Exception e) {

		}
		return 0;
	}

}
